package com.qys.livesMall.system.controller.sys;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qys.livesMall.common.result.R;
import com.qys.livesMall.framework.view.BaseQuery;
import com.qys.livesMall.system.model.dto.sys.SysPaymentPlatformDTO;
import com.qys.livesMall.system.model.vo.sys.SysPaymentPlatformVO;
import com.qys.livesMall.system.service.SysPaymentPlatformService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 支付平台 前端控制器
 * </p>
 *
 * @author 
 * @since 2023-11-06
 */
@RestController
@RequestMapping("/sys/sysPaymentPlatform")
@Tag(name = "支付平台", description = "支付平台")
public class SysPaymentPlatformController {

    @Resource
    private SysPaymentPlatformService sysPaymentPlatformService;

    @Operation(summary = "查询支付平台列表")
    @PostMapping("/query")
    public R<IPage<SysPaymentPlatformVO>> query(@RequestBody @Validated BaseQuery query){
        return R.ok(sysPaymentPlatformService.queryPage(query));
    }

    @Operation(summary = "新增支付平台")
    @PostMapping("/add")
    public R add(@RequestBody @Validated SysPaymentPlatformDTO dto) {
        return sysPaymentPlatformService.add(dto)? R.ok():R.fail();
    }

    @Operation(summary = "修改支付平台")
    @PostMapping("/edit")
    public R edit(@RequestBody @Validated SysPaymentPlatformDTO dto) {
        return sysPaymentPlatformService.edit(dto)? R.ok():R.fail();
    }

    @Operation(summary = "删除")
    @DeleteMapping(value = "/delete/{id}")
    public R delete(@PathVariable Long id){
        sysPaymentPlatformService.removeById(id);
        return R.ok();
    }
}
